package com.lin.cms.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.lin.cms.domain.VoteRecord;

public class VoteRecordValidator implements Validator {

	@SuppressWarnings("unchecked")
	public boolean supports(Class clazz) {
		return VoteRecord.class.isAssignableFrom(clazz);
	}

	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "voterecoredId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "votetopicId", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "voteTime", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "voteIp", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "voteCookie", "required");
	}

}
